/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * articulos_sie_inveprogramados_agregar.java
 *
 * Created on 17/06/2011, 10:19:42 AM
 */

package sie_invdis;




import java.sql.*;
import javax.swing.*;

import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.JTable.*;
import java.awt.*;
import java.util.Date;
import java.util.Calendar;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.text.*;
/**
 *
 * @author Michelle
 */
public class articulos_sie_inveprogramados_agregar extends javax.swing.JFrame {

      private javax.swing.table.DefaultTableModel jtable_modelo;
      private javax.swing.table.DefaultTableModel jtable_modelo_articulosainve;

      private JTable jtable_tiendas;

      private int buscamp=1,controlcombo=0,controlcombo2=0;
      private int opbuscamp=1;
      private int control_enter=0;
      private bd_conexion x = new bd_conexion() ;
       //se creaa la variable resultset
      private ResultSet rs = null;
      private SimpleDateFormat formateador = new SimpleDateFormat("dd-MM-yyyy");
      private SimpleDateFormat formateadoresta = new SimpleDateFormat("yyyy-MM-dd");
       //llamo almetodo para establecer la conexion

    /** Creates new form articulos_sie_inveprogramados_agregar */
    public articulos_sie_inveprogramados_agregar() {
    this.iniciar_modelo_de_tabla();
    this.iniciar_modelo_articulosinventariar();
        initComponents();

    this.buttonGroup1.setSelected(jrb_bclave.getModel(), true);
    this.buttonGroup2.setSelected(jrb_obexacto.getModel(), true);
    this.jtf_busqueda.requestFocus();

     java.util.Date fecha=new Date();
     this.jdc_fechadocto.setDate(fecha);

    jtb_catalogo_articulos.getColumnModel().getColumn(0).setPreferredWidth(60);//tem ent
    jtb_catalogo_articulos.getColumnModel().getColumn(1).setPreferredWidth(60);//familia
    jtb_catalogo_articulos.getColumnModel().getColumn(2).setPreferredWidth(60);//subfam.

    jtb_catalogo_articulos.getColumnModel().getColumn(3).setPreferredWidth(15);//id
    jtb_catalogo_articulos.getColumnModel().getColumn(4).setPreferredWidth(45);//clave
    jtb_catalogo_articulos.getColumnModel().getColumn(5).setPreferredWidth(80);//descrip.
    jtb_catalogo_articulos.getColumnModel().getColumn(6).setPreferredWidth(45);//item
    jtb_catalogo_articulos.getColumnModel().getColumn(7).setPreferredWidth(15);//precio
  
    jtb_catalogo_articulos.getTableHeader().setBackground(Color.yellow);
    jtb_catalogo_articulos.requestFocus();

    this.loadcombotipocongelar();
    this.loadcombo();
    this.loadcombobodegas();
    controlcombo2=1;
    }

 private void iniciar_modelo_de_tabla()
    {
        jtable_modelo=new javax.swing.table.DefaultTableModel();//Creo el modelo
        jtable_modelo.addColumn("<html><b>Temp. Ent.</b></html>");
        jtable_modelo.addColumn("<html><b>Familia</b></html>");
        jtable_modelo.addColumn("<html><b>Sub_fam.</b></html>");
        jtable_modelo.addColumn("<html><b>Id</b></html>");
        jtable_modelo.addColumn("<html><b>Clave</b></html>");
        jtable_modelo.addColumn("<html><b>Descripcion.</b></html>");
        jtable_modelo.addColumn("<html><b>Item.</b></html>");
        jtable_modelo.addColumn("<html><b>Precio</b></html>");
    }

  private void iniciar_modelo_articulosinventariar()
    {
        jtable_modelo_articulosainve=new javax.swing.table.DefaultTableModel();//Creo el modelo
        jtable_modelo_articulosainve.addColumn("<html><b>Temp. Ent.</b></html>");
        jtable_modelo_articulosainve.addColumn("<html><b>Familia</b></html>");
        jtable_modelo_articulosainve.addColumn("<html><b>Sub_fam.</b></html>");
        jtable_modelo_articulosainve.addColumn("<html><b>Id</b></html>");
        jtable_modelo_articulosainve.addColumn("<html><b>Clave</b></html>");
        jtable_modelo_articulosainve.addColumn("<html><b>Descripcion.</b></html>");
        jtable_modelo_articulosainve.addColumn("<html><b>Item.</b></html>");
        jtable_modelo_articulosainve.addColumn("<html><b>Precio</b></html>");
    }

  private void loadcombotipocongelar(){
          this.jcbx_tipoelemento.addItem("0:Elegir Tipo Inventario");
            try
            {
               rs = x.sieuno_executediversosv2("select * from x1sieuno_articulo_inven_fisico_formascongelar() as (id smallint,descrip character varying(40));",variables_global.getconexiongral());
               while (rs.next())
                    {
                      this.jcbx_tipoelemento.addItem(rs.getString("id")+":"+rs.getString("descrip"));
                    }
            }
            catch(Exception e)
            {
                System.out.println(e.getMessage());
            }
}
 private void loadcombo(){
     this.jcbx_tiendas.addItem("0:Todas");
     try
            {
               rs = x.sieuno_executediversosv2("select * from x1distribucion_tiendas_activas(3,'','') as (tie_descri character varying(35),tie_id integer,tie_desesque character varying(25),idclie character varying(12));",variables_global.getconexiongral());
               while (rs.next())
                    {
                        this.jcbx_tiendas.addItem(rs.getString("tie_id")+":"+rs.getString("tie_descri"));
                    }
        }
            catch(Exception e)
            {
                System.out.println(e.getMessage());
            }
    }
private void loadcombobodegas(){
     this.jcbx_tiendas1.addItem("0:Todas");
     try
            {
               rs = x.sieuno_executediversosv2("select * from x1distribucion_tiendas_activas(4,'','') as (tie_descri character varying(35),tie_id integer,tie_desesque character varying(25),idclie character varying(12));",variables_global.getconexiongral());
               while (rs.next())
                    {
                        this.jcbx_tiendas1.addItem(rs.getString("tie_id")+":"+rs.getString("tie_descri"));
                    }
        }
            catch(Exception e)
            {
                System.out.println(e.getMessage());
            }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtb_catalogo_articulos = new javax.swing.JTable(){
            public boolean isCellEditable(int rowIndex, int mColIndex) {
                return false;
            }}
            ;
            jbtn_agregar = new javax.swing.JButton();
            jchbx_eliminarfila = new javax.swing.JCheckBox();
            jPanel1 = new javax.swing.JPanel();
            jrb_bclave = new javax.swing.JRadioButton();
            jrb_bdescrip = new javax.swing.JRadioButton();
            jtf_busqueda = new javax.swing.JTextField();
            jbtn_buscar = new javax.swing.JButton();
            jrb_bitem = new javax.swing.JRadioButton();
            jrb_bprecio = new javax.swing.JRadioButton();
            jrb_obexacto = new javax.swing.JRadioButton();
            jrb_obcomienza = new javax.swing.JRadioButton();
            jrb_obaniway = new javax.swing.JRadioButton();
            jrb_bidfam = new javax.swing.JRadioButton();
            jrb_bidsubfam = new javax.swing.JRadioButton();
            jrb_bdessubfam = new javax.swing.JRadioButton();
            jPanel2 = new javax.swing.JPanel();
            jScrollPane2 = new javax.swing.JScrollPane();
            jtb_articulos_programados = new javax.swing.JTable(){
                public boolean isCellEditable(int rowIndex, int mColIndex) {
                    return false;
                }}
                ;
                jbtn_guardar = new javax.swing.JButton();
                jcbx_limpiararticulos = new javax.swing.JCheckBox();
                jchbx_eliminarfila1 = new javax.swing.JCheckBox();
                jPanel4 = new javax.swing.JPanel();
                jLabel1 = new javax.swing.JLabel();
                jcbx_tipoelemento = new javax.swing.JComboBox();
                jLabel2 = new javax.swing.JLabel();
                jtf_descripcion = new javax.swing.JTextField();
                jdc_fechadocto = new com.toedter.calendar.JDateChooser();
                jLabel3 = new javax.swing.JLabel();
                jLabel4 = new javax.swing.JLabel();
                jcbx_tiendas = new javax.swing.JComboBox();
                jLabel5 = new javax.swing.JLabel();
                jtf_observacion = new javax.swing.JTextField();
                jLabel6 = new javax.swing.JLabel();
                jcbx_tiendas1 = new javax.swing.JComboBox();
                jtf_idesquema = new javax.swing.JTextField();
                jLabel7 = new javax.swing.JLabel();
                jMenuBar1 = new javax.swing.JMenuBar();
                jMenu1 = new javax.swing.JMenu();
                jmni_salir = new javax.swing.JMenuItem();
                jMenu2 = new javax.swing.JMenu();
                jmni_escape = new javax.swing.JMenuItem();
                jMenu3 = new javax.swing.JMenu();

                setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
                org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(sie_invdis.Sie_invdisApp.class).getContext().getResourceMap(articulos_sie_inveprogramados_agregar.class);
                setTitle(resourceMap.getString("Form.title")); // NOI18N
                setName("Form"); // NOI18N

                jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel3.border.title"))); // NOI18N
                jPanel3.setName("jPanel3"); // NOI18N

                jScrollPane1.setName("jScrollPane1"); // NOI18N

                jtb_catalogo_articulos.setModel(this.jtable_modelo);
                jtb_catalogo_articulos.setName("jtb_catalogo_articulos"); // NOI18N
                jtb_catalogo_articulos.setRowHeight(20);
                jtb_catalogo_articulos.addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseClicked(java.awt.event.MouseEvent evt) {
                        jtb_catalogo_articulosMouseClicked(evt);
                    }
                });
                jtb_catalogo_articulos.addKeyListener(new java.awt.event.KeyAdapter() {
                    public void keyPressed(java.awt.event.KeyEvent evt) {
                        jtb_catalogo_articulosKeyPressed(evt);
                    }
                });
                jScrollPane1.setViewportView(jtb_catalogo_articulos);

                jbtn_agregar.setIcon(resourceMap.getIcon("jbtn_agregar.icon")); // NOI18N
                jbtn_agregar.setText(resourceMap.getString("jbtn_agregar.text")); // NOI18N
                jbtn_agregar.setName("jbtn_agregar"); // NOI18N
                jbtn_agregar.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jbtn_agregarActionPerformed(evt);
                    }
                });

                jchbx_eliminarfila.setText(resourceMap.getString("jchbx_eliminarfila.text")); // NOI18N
                jchbx_eliminarfila.setName("jchbx_eliminarfila"); // NOI18N
                jchbx_eliminarfila.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jchbx_eliminarfilaActionPerformed(evt);
                    }
                });

                javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
                jPanel3.setLayout(jPanel3Layout);
                jPanel3Layout.setHorizontalGroup(
                    jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 513, Short.MAX_VALUE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jchbx_eliminarfila)
                        .addGap(297, 297, 297)
                        .addComponent(jbtn_agregar))
                );
                jPanel3Layout.setVerticalGroup(
                    jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 395, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jbtn_agregar)
                            .addComponent(jchbx_eliminarfila)))
                );

                jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel1.border.title"))); // NOI18N
                jPanel1.setName("jPanel1"); // NOI18N

                buttonGroup1.add(jrb_bclave);
                jrb_bclave.setText(resourceMap.getString("jrb_bclave.text")); // NOI18N
                jrb_bclave.setToolTipText(resourceMap.getString("jrb_bclave.toolTipText")); // NOI18N
                jrb_bclave.setActionCommand(resourceMap.getString("jrb_bclave.actionCommand")); // NOI18N
                jrb_bclave.setName("jrb_bclave"); // NOI18N
                jrb_bclave.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jrb_bclaveActionPerformed(evt);
                    }
                });

                buttonGroup1.add(jrb_bdescrip);
                jrb_bdescrip.setText(resourceMap.getString("jrb_bdescrip.text")); // NOI18N
                jrb_bdescrip.setToolTipText(resourceMap.getString("jrb_bdescrip.toolTipText")); // NOI18N
                jrb_bdescrip.setActionCommand(resourceMap.getString("jrb_bdescrip.actionCommand")); // NOI18N
                jrb_bdescrip.setName("jrb_bdescrip"); // NOI18N
                jrb_bdescrip.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jrb_bdescripActionPerformed(evt);
                    }
                });

                jtf_busqueda.setToolTipText(resourceMap.getString("jtf_busqueda.toolTipText")); // NOI18N
                jtf_busqueda.setName("jtf_busqueda"); // NOI18N
                jtf_busqueda.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jtf_busquedaActionPerformed(evt);
                    }
                });

                jbtn_buscar.setIcon(resourceMap.getIcon("jbtn_buscar.icon")); // NOI18N
                jbtn_buscar.setText(resourceMap.getString("jbtn_buscar.text")); // NOI18N
                jbtn_buscar.setName("jbtn_buscar"); // NOI18N
                jbtn_buscar.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jbtn_buscarActionPerformed(evt);
                    }
                });

                buttonGroup1.add(jrb_bitem);
                jrb_bitem.setText(resourceMap.getString("jrb_bitem.text")); // NOI18N
                jrb_bitem.setToolTipText(resourceMap.getString("jrb_bitem.toolTipText")); // NOI18N
                jrb_bitem.setActionCommand(resourceMap.getString("jrb_bitem.actionCommand")); // NOI18N
                jrb_bitem.setName("jrb_bitem"); // NOI18N
                jrb_bitem.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jrb_bitemActionPerformed(evt);
                    }
                });

                buttonGroup1.add(jrb_bprecio);
                jrb_bprecio.setText(resourceMap.getString("jrb_bprecio.text")); // NOI18N
                jrb_bprecio.setToolTipText(resourceMap.getString("jrb_bprecio.toolTipText")); // NOI18N
                jrb_bprecio.setActionCommand(resourceMap.getString("jrb_bprecio.actionCommand")); // NOI18N
                jrb_bprecio.setName("jrb_bprecio"); // NOI18N
                jrb_bprecio.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jrb_bprecioActionPerformed(evt);
                    }
                });

                buttonGroup2.add(jrb_obexacto);
                jrb_obexacto.setText(resourceMap.getString("jrb_obexacto.text")); // NOI18N
                jrb_obexacto.setToolTipText(resourceMap.getString("jrb_obexacto.toolTipText")); // NOI18N
                jrb_obexacto.setActionCommand(resourceMap.getString("jrb_obexacto.actionCommand")); // NOI18N
                jrb_obexacto.setName("jrb_obexacto"); // NOI18N
                jrb_obexacto.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jrb_obexactoActionPerformed(evt);
                    }
                });

                buttonGroup2.add(jrb_obcomienza);
                jrb_obcomienza.setText(resourceMap.getString("jrb_obcomienza.text")); // NOI18N
                jrb_obcomienza.setToolTipText(resourceMap.getString("jrb_obcomienza.toolTipText")); // NOI18N
                jrb_obcomienza.setActionCommand(resourceMap.getString("jrb_obcomienza.actionCommand")); // NOI18N
                jrb_obcomienza.setName("jrb_obcomienza"); // NOI18N
                jrb_obcomienza.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jrb_obcomienzaActionPerformed(evt);
                    }
                });

                buttonGroup2.add(jrb_obaniway);
                jrb_obaniway.setText(resourceMap.getString("jrb_obaniway.text")); // NOI18N
                jrb_obaniway.setToolTipText(resourceMap.getString("jrb_obaniway.toolTipText")); // NOI18N
                jrb_obaniway.setActionCommand(resourceMap.getString("jrb_obaniway.actionCommand")); // NOI18N
                jrb_obaniway.setName("jrb_obaniway"); // NOI18N
                jrb_obaniway.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jrb_obaniwayActionPerformed(evt);
                    }
                });

                buttonGroup1.add(jrb_bidfam);
                jrb_bidfam.setText(resourceMap.getString("jrb_bidfam.text")); // NOI18N
                jrb_bidfam.setToolTipText(resourceMap.getString("jrb_bidfam.toolTipText")); // NOI18N
                jrb_bidfam.setActionCommand(resourceMap.getString("jrb_bidfam.actionCommand")); // NOI18N
                jrb_bidfam.setName("jrb_bidfam"); // NOI18N
                jrb_bidfam.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jrb_bidfamActionPerformed(evt);
                    }
                });

                buttonGroup1.add(jrb_bidsubfam);
                jrb_bidsubfam.setText(resourceMap.getString("jrb_bidsubfam.text")); // NOI18N
                jrb_bidsubfam.setToolTipText(resourceMap.getString("jrb_bidsubfam.toolTipText")); // NOI18N
                jrb_bidsubfam.setActionCommand(resourceMap.getString("jrb_bidsubfam.actionCommand")); // NOI18N
                jrb_bidsubfam.setName("jrb_bidsubfam"); // NOI18N
                jrb_bidsubfam.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jrb_bidsubfamActionPerformed(evt);
                    }
                });

                buttonGroup1.add(jrb_bdessubfam);
                jrb_bdessubfam.setText(resourceMap.getString("jrb_bdessubfam.text")); // NOI18N
                jrb_bdessubfam.setToolTipText(resourceMap.getString("jrb_bdessubfam.toolTipText")); // NOI18N
                jrb_bdessubfam.setActionCommand(resourceMap.getString("jrb_bdessubfam.actionCommand")); // NOI18N
                jrb_bdessubfam.setName("jrb_bdessubfam"); // NOI18N
                jrb_bdessubfam.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jrb_bdessubfamActionPerformed(evt);
                    }
                });

                javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
                jPanel1.setLayout(jPanel1Layout);
                jPanel1Layout.setHorizontalGroup(
                    jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jrb_obexacto)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jrb_obcomienza)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jrb_obaniway)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jtf_busqueda))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jrb_bclave)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jrb_bdescrip)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jrb_bitem)
                                .addGap(4, 4, 4)
                                .addComponent(jrb_bprecio)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jrb_bidfam)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jrb_bidsubfam)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jrb_bdessubfam)
                            .addComponent(jbtn_buscar)))
                );
                jPanel1Layout.setVerticalGroup(
                    jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jrb_obexacto)
                                .addComponent(jrb_obcomienza))
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jrb_obaniway)
                                .addComponent(jtf_busqueda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jbtn_buscar)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 39, Short.MAX_VALUE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jrb_bclave)
                            .addComponent(jrb_bdescrip)
                            .addComponent(jrb_bprecio)
                            .addComponent(jrb_bitem)
                            .addComponent(jrb_bidfam)
                            .addComponent(jrb_bidsubfam)
                            .addComponent(jrb_bdessubfam)))
                );

                jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel2.border.title"))); // NOI18N
                jPanel2.setName("jPanel2"); // NOI18N

                jScrollPane2.setName("jScrollPane2"); // NOI18N

                jtb_articulos_programados.setModel(this.jtable_modelo_articulosainve);
                jtb_articulos_programados.setName("jtb_articulos_programados"); // NOI18N
                jtb_articulos_programados.setRowHeight(20);
                jtb_articulos_programados.addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseClicked(java.awt.event.MouseEvent evt) {
                        jtb_articulos_programadosMouseClicked(evt);
                    }
                });
                jtb_articulos_programados.addKeyListener(new java.awt.event.KeyAdapter() {
                    public void keyPressed(java.awt.event.KeyEvent evt) {
                        jtb_articulos_programadosKeyPressed(evt);
                    }
                });
                jScrollPane2.setViewportView(jtb_articulos_programados);

                jbtn_guardar.setIcon(resourceMap.getIcon("jbtn_guardar.icon")); // NOI18N
                jbtn_guardar.setText(resourceMap.getString("jbtn_guardar.text")); // NOI18N
                jbtn_guardar.setName("jbtn_guardar"); // NOI18N
                jbtn_guardar.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jbtn_guardarActionPerformed(evt);
                    }
                });

                jcbx_limpiararticulos.setText(resourceMap.getString("jcbx_limpiararticulos.text")); // NOI18N
                jcbx_limpiararticulos.setName("jcbx_limpiararticulos"); // NOI18N
                jcbx_limpiararticulos.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jcbx_limpiararticulosActionPerformed(evt);
                    }
                });

                jchbx_eliminarfila1.setText(resourceMap.getString("jchbx_eliminarfila1.text")); // NOI18N
                jchbx_eliminarfila1.setName("jchbx_eliminarfila1"); // NOI18N
                jchbx_eliminarfila1.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jchbx_eliminarfila1ActionPerformed(evt);
                    }
                });

                javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
                jPanel2.setLayout(jPanel2Layout);
                jPanel2Layout.setHorizontalGroup(
                    jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                                .addComponent(jchbx_eliminarfila1)
                                .addGap(127, 127, 127)
                                .addComponent(jcbx_limpiararticulos)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 72, Short.MAX_VALUE)
                                .addComponent(jbtn_guardar))
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 492, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap())
                );
                jPanel2Layout.setVerticalGroup(
                    jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 383, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jbtn_guardar)
                            .addComponent(jcbx_limpiararticulos)
                            .addComponent(jchbx_eliminarfila1)))
                );

                jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel4.border.title"))); // NOI18N
                jPanel4.setName("jPanel4"); // NOI18N

                jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
                jLabel1.setName("jLabel1"); // NOI18N

                jcbx_tipoelemento.setName("jcbx_tipoelemento"); // NOI18N

                jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
                jLabel2.setName("jLabel2"); // NOI18N

                jtf_descripcion.setText(resourceMap.getString("jtf_descripcion.text")); // NOI18N
                jtf_descripcion.setName("jtf_descripcion"); // NOI18N

                jdc_fechadocto.setName("jdc_fechadocto"); // NOI18N

                jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
                jLabel3.setName("jLabel3"); // NOI18N

                jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
                jLabel4.setName("jLabel4"); // NOI18N

                jcbx_tiendas.setToolTipText(resourceMap.getString("jcbx_tiendas.toolTipText")); // NOI18N
                jcbx_tiendas.setName("jcbx_tiendas"); // NOI18N
                jcbx_tiendas.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jcbx_tiendasActionPerformed(evt);
                    }
                });

                jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
                jLabel5.setName("jLabel5"); // NOI18N

                jtf_observacion.setText(resourceMap.getString("jtf_observacion.text")); // NOI18N
                jtf_observacion.setName("jtf_observacion"); // NOI18N

                jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
                jLabel6.setName("jLabel6"); // NOI18N

                jcbx_tiendas1.setToolTipText(resourceMap.getString("jcbx_tiendas1.toolTipText")); // NOI18N
                jcbx_tiendas1.setName("jcbx_tiendas1"); // NOI18N
                jcbx_tiendas1.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jcbx_tiendas1ActionPerformed(evt);
                    }
                });

                jtf_idesquema.setEditable(false);
                jtf_idesquema.setText(resourceMap.getString("jtf_idesquema.text")); // NOI18N
                jtf_idesquema.setName("jtf_idesquema"); // NOI18N

                jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
                jLabel7.setName("jLabel7"); // NOI18N

                javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
                jPanel4.setLayout(jPanel4Layout);
                jPanel4Layout.setHorizontalGroup(
                    jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel4Layout.createSequentialGroup()
                                    .addComponent(jLabel2)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jtf_descripcion, javax.swing.GroupLayout.DEFAULT_SIZE, 247, Short.MAX_VALUE))
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel4Layout.createSequentialGroup()
                                    .addComponent(jLabel5)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jtf_observacion, javax.swing.GroupLayout.DEFAULT_SIZE, 240, Short.MAX_VALUE)))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jcbx_tipoelemento, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jdc_fechadocto, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGap(4, 4, 4)
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addComponent(jLabel4)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jcbx_tiendas, 0, 129, Short.MAX_VALUE))
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addComponent(jLabel6)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel7)
                                            .addComponent(jcbx_tiendas1, 0, 118, Short.MAX_VALUE))))
                                .addContainerGap())
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jtf_idesquema, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap())))
                );
                jPanel4Layout.setVerticalGroup(
                    jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel1)
                                    .addComponent(jcbx_tipoelemento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel3))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel2)
                                    .addComponent(jtf_descripcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jcbx_tiendas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(jdc_fechadocto, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jcbx_tiendas1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(jtf_observacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jtf_idesquema, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                );

                jMenuBar1.setName("jMenuBar1"); // NOI18N

                jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
                jMenu1.setName("jMenu1"); // NOI18N

                jmni_salir.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK));
                jmni_salir.setIcon(resourceMap.getIcon("jmni_salir.icon")); // NOI18N
                jmni_salir.setText(resourceMap.getString("jmni_salir.text")); // NOI18N
                jmni_salir.setName("jmni_salir"); // NOI18N
                jmni_salir.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jmni_salirActionPerformed(evt);
                    }
                });
                jMenu1.add(jmni_salir);

                jMenuBar1.add(jMenu1);

                jMenu2.setText(resourceMap.getString("jMenu2.text")); // NOI18N
                jMenu2.setName("jMenu2"); // NOI18N

                jmni_escape.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0));
                jmni_escape.setText(resourceMap.getString("jmni_escape.text")); // NOI18N
                jmni_escape.setName("jmni_escape"); // NOI18N
                jmni_escape.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jmni_escapeActionPerformed(evt);
                    }
                });
                jMenu2.add(jmni_escape);

                jMenuBar1.add(jMenu2);

                jMenu3.setText(resourceMap.getString("jMenu3.text")); // NOI18N
                jMenu3.setName("jMenu3"); // NOI18N
                jMenuBar1.add(jMenu3);

                setJMenuBar(jMenuBar1);

                javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
                getContentPane().setLayout(layout);
                layout.setHorizontalGroup(
                    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel1, 0, 529, Short.MAX_VALUE)
                            .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jPanel2, 0, 507, Short.MAX_VALUE)
                            .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                );
                layout.setVerticalGroup(
                    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap())
                );

                pack();
            }// </editor-fold>//GEN-END:initComponents

    private void jtb_catalogo_articulosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jtb_catalogo_articulosMouseClicked
        // TODO add your handling code here:
}//GEN-LAST:event_jtb_catalogo_articulosMouseClicked

    private void jtb_catalogo_articulosKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtb_catalogo_articulosKeyPressed
        // TODO add your handling code here:
        //control enter se utiliza por un rollo de que al dar enter se mostraban dos veces  el documento
        System.out.println(evt.getKeyCode());
        if (evt.getKeyCode() == 10) {
            if (control_enter > 1) {
                try {
                    //si entra al if inicializo la variable para evitar qu al regreso entre una vez mas
                    control_enter=0;
                    System.out.println(control_enter);
                    int fila = jtb_catalogo_articulos.getSelectedRow();
                    Object valor = jtb_catalogo_articulos.getValueAt(fila, 3);
                    //JFrame mainFrame = Sie_invdisApp.getApplication().getMainFrame();
                    articulos_sie_editar fase=new articulos_sie_editar(valor.toString());
                    fase.setVisible(true);
                } catch (Exception ex) {
                    System.out.println("ERROR no ha elegido en el cuadro de texto");
                }
            }
        }
        control_enter+=1;
}//GEN-LAST:event_jtb_catalogo_articulosKeyPressed

    private void jbtn_agregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_agregarActionPerformed
        // TODO add your handling code here:
if(JOptionPane.showConfirmDialog(null, "Desea Agregar Estos Articulos a Inventario?")==0)
        {
                   this.tabla_articulos_exportar();
        }
 
}//GEN-LAST:event_jbtn_agregarActionPerformed

    private void jrb_bclaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrb_bclaveActionPerformed
        // TODO add your handling code here:
        buscamp=Integer.parseInt(evt.getActionCommand().toString());
    }//GEN-LAST:event_jrb_bclaveActionPerformed

    private void jrb_bdescripActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrb_bdescripActionPerformed
        // TODO add your handling code here:
        buscamp=Integer.parseInt(evt.getActionCommand().toString());
    }//GEN-LAST:event_jrb_bdescripActionPerformed

    private void jtf_busquedaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_busquedaActionPerformed
        // TODO add your handling code here:
        this.jbtn_buscarActionPerformed(evt);
}//GEN-LAST:event_jtf_busquedaActionPerformed

    private void jbtn_buscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_buscarActionPerformed
        // TODO add your handling code here:
        // this.jtf_busqueda.getText();
        if(JOptionPane.showConfirmDialog(null, "Estan Correctos sus Datos?")==0) {

            this.executabusqueda(buscamp,opbuscamp,this.jtf_busqueda.getText().trim().toUpperCase());

        } else {

            this.jtf_busqueda.requestFocus();

        }
    }//GEN-LAST:event_jbtn_buscarActionPerformed

    private void jrb_bitemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrb_bitemActionPerformed
        // TODO add your handling code here:
        buscamp=Integer.parseInt(evt.getActionCommand().toString());
    }//GEN-LAST:event_jrb_bitemActionPerformed

    private void jrb_bprecioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrb_bprecioActionPerformed
        // TODO add your handling code here:
        buscamp=Integer.parseInt(evt.getActionCommand().toString());
    }//GEN-LAST:event_jrb_bprecioActionPerformed

    private void jrb_obexactoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrb_obexactoActionPerformed
        // TODO add your handling code here:
        opbuscamp=Integer.parseInt(evt.getActionCommand().toString());
}//GEN-LAST:event_jrb_obexactoActionPerformed

    private void jrb_obcomienzaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrb_obcomienzaActionPerformed
        // TODO add your handling code here:
        opbuscamp=Integer.parseInt(evt.getActionCommand().toString());
}//GEN-LAST:event_jrb_obcomienzaActionPerformed

    private void jrb_obaniwayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrb_obaniwayActionPerformed
        // TODO add your handling code here:
        opbuscamp=Integer.parseInt(evt.getActionCommand().toString());
}//GEN-LAST:event_jrb_obaniwayActionPerformed

    private void jrb_bidfamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrb_bidfamActionPerformed
        // TODO add your handling code here:
        buscamp=Integer.parseInt(evt.getActionCommand().toString());
}//GEN-LAST:event_jrb_bidfamActionPerformed

    private void jrb_bidsubfamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrb_bidsubfamActionPerformed
        // TODO add your handling code here:
        buscamp=Integer.parseInt(evt.getActionCommand().toString());
}//GEN-LAST:event_jrb_bidsubfamActionPerformed

    private void jrb_bdessubfamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrb_bdessubfamActionPerformed
        // TODO add your handling code here:
        buscamp=Integer.parseInt(evt.getActionCommand().toString());
}//GEN-LAST:event_jrb_bdessubfamActionPerformed

    private void jmni_salirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_salirActionPerformed
        // TODO add your handling code here:
        if(JOptionPane.showConfirmDialog(null, "Realmente Desea Salir?")==0)
            {
                this.dispose();
            }
    }//GEN-LAST:event_jmni_salirActionPerformed

    private void jtb_articulos_programadosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jtb_articulos_programadosMouseClicked
        // TODO add your handling code here:
}//GEN-LAST:event_jtb_articulos_programadosMouseClicked

    private void jtb_articulos_programadosKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtb_articulos_programadosKeyPressed
        // TODO add your handling code here:
}//GEN-LAST:event_jtb_articulos_programadosKeyPressed

    private void jcbx_tiendasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbx_tiendasActionPerformed
        // TODO add your handling code here:
 if (controlcombo2 > 0 ) {
                if(JOptionPane.showConfirmDialog(null, "Estan Correctos sus Datos?")==0)
                        {
                            String arreglo_idtie[]=this.jcbx_tiendas.getSelectedItem().toString().split(":");
                            this.jtf_idesquema.setText( arreglo_idtie[0]);
                        }
          }
}//GEN-LAST:event_jcbx_tiendasActionPerformed

    private void jbtn_guardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_guardarActionPerformed
        // TODO add your handling code here:
         String arreglo_puesto[]=this.jcbx_tipoelemento.getSelectedItem().toString().split(":");
        if (arreglo_puesto[0].equals("51"))
            {
                this.tabla_articulos_inventariados("GENERAL","GENERAL","GENERAL","GENERAL","GENERAL","GENERAL","GENERAL","GENERAL");
            }

    if(JOptionPane.showConfirmDialog(null, "Estan Correctos tus datos?")==0)
        {
        int index=this.jcbx_tipoelemento.getSelectedIndex();
        if (index>0)
        {
        int numerofilas=this.jtable_modelo_articulosainve.getRowCount(),error=0;
        String valorrespuesta="";
        for(int i = 0 ;i < numerofilas; i++)
           {
                 jtable_modelo_articulosainve.setValueAt(".",i ,0);
                 jtable_modelo_articulosainve.setValueAt(".",i ,1);
                 jtable_modelo_articulosainve.setValueAt(".",i ,2);
                 jtable_modelo_articulosainve.setValueAt(".",i ,3);
                 jtable_modelo_articulosainve.setValueAt(".",i ,5);
                 jtable_modelo_articulosainve.setValueAt(".",i ,6);
           }
             //this.quitarpreguntas();
            java.util.Vector arreglorespuestas=this.jtable_modelo_articulosainve.getDataVector();
            String preguntasyres_papostgresql=arreglorespuestas.toString();
            preguntasyres_papostgresql=preguntasyres_papostgresql.replace('[','{');
            preguntasyres_papostgresql=preguntasyres_papostgresql.replace(']','}');
            preguntasyres_papostgresql=preguntasyres_papostgresql.replace("null",".");

            String arreglo_tie[]=this.jcbx_tiendas.getSelectedItem().toString().split(":");
            String arreglo_tipo[]=this.jcbx_tipoelemento.getSelectedItem().toString().split(":");
            String texto="select * from x1sieuno_articulo_inven_programarv2("+this.jtf_idesquema.getText()+","+arreglo_tipo[0]+",'"+this.fechaamericana(this.jdc_fechadocto.getDate())+"','"+this.jtf_descripcion.getText().trim().toUpperCase()+"','"+this.jtf_observacion.getText().trim().toUpperCase()+"',0,'"+preguntasyres_papostgresql+"')";
            System.out.println(texto);
            try {
                rs=x.sieuno_executediversosv2(texto,variables_global.getconexiongral());
                 while (rs.next())
                       {
                       if (rs.getInt(1) > 0)
                               {
                                      JOptionPane.showMessageDialog(null,"Guardado Correctament, Gracias", "Sistema Integral(Alta Inventarios) : Alta",1);
                               }
                             else
                               {
                                    JOptionPane.showMessageDialog(null," Error Verifique sus Indicador", "Sistema Integral(Indicadores) : Error",1);
                               }
                      }
            } catch(Exception e)
               {
                   System.out.println(e.getMessage());
                   JOptionPane.showMessageDialog(null,"Indicador Incorrecto Consulte a su Administrador", "Sistema Integral(Indicadores) : Error",1);
               }
       //     this.LimpiarJTable();
       
       }//fin del if de index
        else
            {
                JOptionPane.showMessageDialog(null,"Seleccione un Tipo de Inventario", "Sistema Integral(Inventario Fisico)",1);
            }
        }//cierra llave si desea guardar inventario
    }//GEN-LAST:event_jbtn_guardarActionPerformed

    private void jmni_escapeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_escapeActionPerformed
        // TODO add your handling code here:
        this.jmni_salirActionPerformed(evt);
    }//GEN-LAST:event_jmni_escapeActionPerformed

    private void jcbx_limpiararticulosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbx_limpiararticulosActionPerformed
        // TODO add your handling code here:
  if(JOptionPane.showConfirmDialog(null, "Realmente Desea Eliminar Articulos?")==0)
            {
                while(jtable_modelo_articulosainve.getRowCount()>0)jtable_modelo_articulosainve.removeRow(0);
            }        
            
    }//GEN-LAST:event_jcbx_limpiararticulosActionPerformed

    private void jchbx_eliminarfilaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jchbx_eliminarfilaActionPerformed
        // TODO add your handling code here:
        int fila = jtb_catalogo_articulos.getSelectedRow();

            if(JOptionPane.showConfirmDialog(null, "Desea Eliminar Fila Seleccionada?")==0) {
                jtable_modelo.removeRow(fila);
        
            }

    }//GEN-LAST:event_jchbx_eliminarfilaActionPerformed

    private void jchbx_eliminarfila1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jchbx_eliminarfila1ActionPerformed
        // TODO add your handling code here:
         int fila = jtb_articulos_programados.getSelectedRow();

            if(JOptionPane.showConfirmDialog(null, "Desea Eliminar Fila Seleccionada?")==0) {
                jtable_modelo_articulosainve.removeRow(fila);
            }

    }//GEN-LAST:event_jchbx_eliminarfila1ActionPerformed

    private void jcbx_tiendas1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbx_tiendas1ActionPerformed
        // TODO add your handling code here:
        if (controlcombo2 > 0 ) {
                if(JOptionPane.showConfirmDialog(null, "Estan Correctos sus Datos?")==0)
                        {
                            String arreglo_idtie[]=this.jcbx_tiendas1.getSelectedItem().toString().split(":");
                            this.jtf_idesquema.setText( arreglo_idtie[0]);
                        }
          }
    }//GEN-LAST:event_jcbx_tiendas1ActionPerformed

private  void ayuda()
    {
        JOptionPane.showMessageDialog(null," 1.-Catalogo de Articulos, cada una de las Opciones se autodescribe brevemente\n 2.- Cada Boton tiene Una letra Resaltada el cual indica su metodo abreviado, uselo si desea mayor rapides ( ejemplo Alt+a obtendra ayuda automaticamente)\n 3.-Para buscar un Articulo Ingrese en el cuadro de texto luego presion Ctrl+B o Precionando el Boton Buscar . \n ", "Sistema Integral(Catalogo de Articulos) : Ayuda",1);
    }

private void crearcomentario()
 {
    String retorno="";
    String comentario=JOptionPane.showInputDialog("Ingresa Tu Sugerencia o Comentario:");
    if (comentario.length()>0)
        {
            rs = x.sieuno_executediversosv2("select * from x1distribucion_bitacorainserta('"+comentario+"', 'Catalogo Articulos');",variables_global.getconexiongral());
            try
            {
               while (rs.next())
                   {
                        retorno=rs.getString(1);
                   }
             }
            catch(Exception e)
                {
                        System.out.println(e.getMessage());
                }
            if (retorno.equals("1"))
                {
                    JOptionPane.showMessageDialog(null,"Gracias Tu comentario ha sido guardado", "Sistema Integral Comentarios",1);
                }
        }
}

 void executabusqueda(int busca, int opbusca,String textobusca)
 {
          while(jtable_modelo.getRowCount()>0)jtable_modelo.removeRow(0);
       System.out.println("busqueda");
        //this.jtb_catalogo_articulos.repaint();
        //invoco al metodo que trae el recordset de datos
       //rs = x.damecat_art(buscamp,opbuscamp,this.jtf_busqueda.getText().toUpperCase());
       String texto="select * from x1sieuno_articulo_catalogov2("+busca+","+opbusca+",'"+textobusca+"') as (id integer, cla character varying(16),cod character varying(16), des character varying(80), ultimocosto numeric,fa integer,sub integer,it character varying(80),pre numeric, fe date, tei smallint,tev smallint,lineaarti smallint,controalmacen character varying(20),statusarticulo smallint,unidadempaque character varying(8),sublinea smallint,ob character varying(80),nomfa character varying(30), nomsub character varying(50),tementr character varying(25),descriplinea character varying(25),describestatus character varying(25),describesublinea character varying(25),describetemventa character varying(25))";
       try
        {
            System.out.println(texto);
            rs = x.sieuno_executediversosv2(texto,variables_global.getconexiongral());
            while (rs.next())
                {
                    jtable_modelo.addRow(new Object[]{rs.getString ("tementr"),rs.getString ("fa")+":"+rs.getString ("nomfa"),rs.getString ("sub")+":"+rs.getString ("nomsub"),rs.getString ("id"),rs.getString ("cla"),rs.getString ("des"),rs.getString ("it"),rs.getString ("pre")});
                }
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
}

private void tabla_articulos_inventariados(String temporada, String familia,String subfamilia,String id, String clave, String descripcion,String item, String precio)
{
   int numeroarticulos=this.jtable_modelo_articulosainve.getRowCount();

   String codigoactual="";

   float cantidadanterior=0,cantidadactual=0,totalpiezasf=0;
   int encontrado=0;
   Object[] fnewRow = new Object[8];
       //invoco al metodo que trae el recordset de datos
   for(int ii=0;ii<numeroarticulos;ii++)
                {
                    codigoactual=jtable_modelo_articulosainve.getValueAt(ii, 4).toString();
                    if (clave.equals(codigoactual))
                        {
                            encontrado=1;
                        }
                }
   if(encontrado==0)
            {
                fnewRow[0]=temporada;
                fnewRow[1]=familia;
                fnewRow[2]=subfamilia;
                fnewRow[3]=id;
                fnewRow[4]=clave;
                fnewRow[5]=descripcion;
                fnewRow[6]=item;
                fnewRow[7]=precio;
                jtable_modelo_articulosainve.addRow(fnewRow);
            }
}

private void tabla_articulos_exportar()
{
   int numeroarticulos=this.jtb_catalogo_articulos.getRowCount();
       //invoco al metodo que trae el recordset de datos
   for(int ii=0;ii<numeroarticulos;ii++)
       {
                this.tabla_articulos_inventariados(jtable_modelo.getValueAt(ii, 0).toString(),jtable_modelo.getValueAt(ii, 1).toString(),jtable_modelo.getValueAt(ii, 2).toString(),jtable_modelo.getValueAt(ii, 3).toString(),jtable_modelo.getValueAt(ii, 4).toString(),jtable_modelo.getValueAt(ii,5).toString(),jtable_modelo.getValueAt(ii, 6).toString(),jtable_modelo.getValueAt(ii, 7).toString());
       }
}
 private String fechaamericana(Date fe) {
       SimpleDateFormat formateadorestaeuropa = new SimpleDateFormat("yyyy-MM-dd");
       String cadenafecha="";
       cadenafecha= formateadorestaeuropa.format(fe);
       return cadenafecha;

    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new articulos_sie_inveprogramados_agregar().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JButton jbtn_agregar;
    private javax.swing.JButton jbtn_buscar;
    private javax.swing.JButton jbtn_guardar;
    private javax.swing.JCheckBox jcbx_limpiararticulos;
    private javax.swing.JComboBox jcbx_tiendas;
    private javax.swing.JComboBox jcbx_tiendas1;
    private javax.swing.JComboBox jcbx_tipoelemento;
    private javax.swing.JCheckBox jchbx_eliminarfila;
    private javax.swing.JCheckBox jchbx_eliminarfila1;
    private com.toedter.calendar.JDateChooser jdc_fechadocto;
    private javax.swing.JMenuItem jmni_escape;
    private javax.swing.JMenuItem jmni_salir;
    private javax.swing.JRadioButton jrb_bclave;
    private javax.swing.JRadioButton jrb_bdescrip;
    private javax.swing.JRadioButton jrb_bdessubfam;
    private javax.swing.JRadioButton jrb_bidfam;
    private javax.swing.JRadioButton jrb_bidsubfam;
    private javax.swing.JRadioButton jrb_bitem;
    private javax.swing.JRadioButton jrb_bprecio;
    private javax.swing.JRadioButton jrb_obaniway;
    private javax.swing.JRadioButton jrb_obcomienza;
    private javax.swing.JRadioButton jrb_obexacto;
    private javax.swing.JTable jtb_articulos_programados;
    private javax.swing.JTable jtb_catalogo_articulos;
    private javax.swing.JTextField jtf_busqueda;
    private javax.swing.JTextField jtf_descripcion;
    private javax.swing.JTextField jtf_idesquema;
    private javax.swing.JTextField jtf_observacion;
    // End of variables declaration//GEN-END:variables

}
